/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						       adjusted_animation_cache.h

	$Header: /game/adjusted_animation_cache.h $

	$NoKeywords: $

 ************************************************************************/

#ifndef ADJUSTED_ANIMATION_CACHE_H_INCLUDED
#define ADJUSTED_ANIMATION_CACHE_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "cached_ptr.h"

class t_animation;
// -----------------------------------------------------
// load a copy of a bitmap and adjust the brightness.  +15 = white, -15 = black.
// ---------------------------------------------------
class t_adjusted_animation_cache_data : public t_abstract_cache_data<t_animation>
{
public:
	typedef t_abstract_cache<t_animation>      t_source_cache;

	t_adjusted_animation_cache_data( t_source_cache const& source, int brightness );
	virtual ~t_adjusted_animation_cache_data();
		                     
protected:
	virtual void            add_reference();
	virtual t_animation*    do_get( t_progress_handler* handler );
	virtual void            remove_reference();

	t_source_cache m_source;
	int            m_brightness;
	int            m_reference_count;
	t_animation*   m_data;
};

class t_adjusted_animation_cache : public t_abstract_cache<t_animation>
{
public:
	typedef t_abstract_cache<t_animation> t_source_cache;

	t_adjusted_animation_cache();
	t_adjusted_animation_cache( t_source_cache const& source, int brightness );
	void init( t_source_cache const& source, int brightness );
};

inline t_adjusted_animation_cache::t_adjusted_animation_cache()
								 : t_abstract_cache<t_animation>( 0 )
{
}

inline t_adjusted_animation_cache::t_adjusted_animation_cache( t_source_cache const& source, int brightness )
	: t_abstract_cache<t_animation>( new t_adjusted_animation_cache_data( source, brightness ) )
{
}

inline void t_adjusted_animation_cache::init( t_source_cache const& source, int brightness )
{
	set( new t_adjusted_animation_cache_data( source, brightness ) );
}

#endif // ADJUSTED_ANIMATION_CACHE_H_INCLUDED